package com.dingreading.cloud.ssxcx.service.impl;

import com.dingreading.cloud.ssxcx.entity.XcxHomeworkFilesTrack;
import com.dingreading.cloud.ssxcx.entity.table.XcxHomeworkFilesTrackTableDef;
import com.dingreading.cloud.ssxcx.mapper.XcxHomeworkFilesTrackMapper;
import com.dingreading.cloud.ssxcx.service.XcxHomeworkFilesTrackService;
import com.mybatisflex.core.query.QueryCondition;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 阿里云文件上传追踪表 服务层实现。
 *
 * @author EDY
 * @since 2025-08-29
 */
@Service
public class XcxHomeworkFilesTrackServiceImpl extends BaseServiceImpl<XcxHomeworkFilesTrackMapper, XcxHomeworkFilesTrack, XcxHomeworkFilesTrackTableDef> implements XcxHomeworkFilesTrackService {

    @Override
    protected XcxHomeworkFilesTrackTableDef getTable() {
        return XcxHomeworkFilesTrackTableDef.xcxHomeworkFilesTrack;
    }

    @Override
    public List<XcxHomeworkFilesTrack> getByFileUrls(List<String> homeworkFileUrls) {
        return getMapper().selectListByCondition(table.url.in(homeworkFileUrls));
    }

    @Override
    public List<XcxHomeworkFilesTrack> getDeleteUrls() {
        QueryCondition condition = QueryCondition.createEmpty()
                .and(table.cleanupTime.isNull())
                .and(table.status.eq(1));
        return getMapper().selectListByCondition(condition);
    }
}
